CC=gcc
AR=ar

CFLAGS=-Wall -O2 -Os -g
INCLUDES = -I./inc
INCLUDES += -I./lib/libfaac/inc
INCLUDES += -I./lib/libfaac/faac
TARGET=to_mp4
# ./lib/libfaac/faac/*.c
SRCS := $(wildcard *.c ./src/*.c ./lib/libfaac/faac/*.c)
LIB_SRCS := $(wildcard ./src/*.c ./lib/libfaac/faac/*.c)
OBJ = ./obj
OBJS := $(patsubst %c,$(OBJ)/%o,$(notdir $(SRCS)))
LIB_OBJS:=$(patsubst %c,$(OBJ)/%o,$(notdir $(LIB_SRCS)))

LIB_NAME = ./lib/libavctomp4.a

all: $(TARGET) out_arm
		@echo $(LIB_OBJS)

out_arm:$(LIB_OBJS) 
	$(AR) -rcs $(LIB_NAME)  $(LIB_OBJS)

$(TARGET):$(OBJS)
	$(CC) $(INCLUDES) $(CFLAGS) -o $@ $^ -lm

$(OBJ)/%.o:%.c 
	$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ -lm

$(OBJ)/%.o:./src/%.c 
	$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ -lm

$(OBJ)/%.o:./lib/libfaac/faac/%.c
	$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ -lm

clean:
	rm -r $(OBJS) $(TARGET) $(LIB_NAME)